<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.keywords" placeholder="订单号" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="dataForm.startTime"
          type="datetime"
          value-format = "yyyy-MM-dd HH:mm:ss"
          placeholder="起始时间">
		    </el-date-picker>
	    </el-form-item>
	    <el-form-item label="">
		    <el-date-picker
          v-model="dataForm.endTime"
          type="datetime"
          value-format = "yyyy-MM-dd HH:mm:ss"
          placeholder="结束时间">
		    </el-date-picker>
	    </el-form-item>
      <el-form-item label="退货类型">
				<el-select v-model="dataForm.returnType" placeholder="退货类型">
					<el-option label="全部" value="" ></el-option>
					<el-option label="仅退款" value="1"></el-option>
					<el-option label="退货并退款" value="2"></el-option>
          <el-option label="换货" value="3"></el-option>
				</el-select>
			</el-form-item>
      <el-form-item label="退货状态">
				<el-select v-model="dataForm.returnStatus" placeholder="退货状态">
					<el-option label="全部" value=""></el-option>
					<el-option label="已申请" value="1"></el-option>
					<el-option label="审核通过" value="2"></el-option>
          <el-option label="成功" value="4"></el-option>
					<el-option label="审核未通过" value="5"></el-option>
          <el-option label="退货失败" value="6"></el-option>
					<el-option label="已撤销" value="7"></el-option>
				</el-select>
			</el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
        <el-button @click="
          dataForm.keywords = ''
          dataForm.startTime = ''
          dataForm.endTime = ''
          dataForm.returnType = ''
          dataForm.returnStatusr = ''
          getDataList()">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      default-expand-all
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-row v-for="(item,index) in props.row.sonOrder" :key="index" :gutter="20">
            <el-col :span="1">
              <el-popover
                placement="right"
                title=""
                trigger="hover">
                <img :src="'http://image.yilianbaihui.cn/consumer/'+item.img"/>
                <img slot="reference" :src="'http://image.yilianbaihui.cn/consumer/'+item.img" style="max-height: 30px;max-width: 80px">
              </el-popover>
            </el-col>
            <el-col :span="10">
              <a :href="'http://www.yilianbaihui.cn/item_show.html?goodsId='+item.goodsId" target="_blank" class="buttonText">{{item.goodsName}}</a>
            </el-col>
            <!-- <el-col :span="3">
              型号:{{item.goodsSerial}}
            </el-col> -->
            <el-col :span="3">
              规格:{{item.specInfo}}
            </el-col>
            <el-col :span="3">
              数量:{{item.deliveryCount}}
            </el-col>
            <!-- <el-col :span="3">
              类型:{{item.priceType === 1 ? '兑换' : '福利'}}
            </el-col> -->
            <el-col :span="3">
              状态:
              <span v-if="item.state === 1">正常</span>
              <span v-if="item.state === 2">退货中</span>
              <span v-if="item.state === 3">退款中</span>
              <span v-if="item.state === 4">换货中</span>
              <span v-if="item.state === 5">已退货</span>
              <span v-if="item.state === 6">已退款</span>
              <span v-if="item.state === 7">已换货</span>
              <span v-if="item.state === 8">退货失败</span>
              <span v-if="item.state === 9">退款失败</span>
              <span v-if="item.state === 10">换货失败</span>
            </el-col>
          </el-row>
        </template>
      </el-table-column>
      <!-- <el-table-column type="expand">
        <template slot-scope="props">
        <el-form label-position="left" inline class="demo-table-expand">
          <el-table :data="props.row.sonOrder">
            <el-table-column>
              <template slot-scope="scope">
                <el-popover
                placement="right"
                title=""
                trigger="hover">
                <img :src="'http://image.yilianbaihui.cn/consumer/'+scope.row.img"/>
                <img slot="reference" :src="'http://image.yilianbaihui.cn/consumer/'+scope.row.img" style="max-height: 30px;max-width: 80px">
                </el-popover>
                <span style="margin-left:20px"><a :href="'http://www.yilianbaihui.cn/goods_'+scope.row.goodsId+'.htm'" target="_blank" class="buttonText">{{scope.row.goodsName}}</a></span>
                <span style="margin-left:120px">规格:{{scope.row.specInfo}}</span>
                <span style="margin-left:120px">数量:{{scope.row.deliveryCount}}</span>
                <span style="margin-left:120px">状态:<span v-if="scope.row.state === 1">正常</span>
                                                    <span v-if="scope.row.state === 2">退货中</span>
                                                    <span v-if="scope.row.state === 3">退款中</span>
                                                    <span v-if="scope.row.state === 4">换货中</span>
                                                    <span v-if="scope.row.state === 5">已退货</span>
                                                    <span v-if="scope.row.state === 6">已退款</span>
                                                    <span v-if="scope.row.state === 7">已换货</span>
                                                    <span v-if="scope.row.state === 8">退货失败</span>
                                                    <span v-if="scope.row.state === 9">退款失败</span>
                                                    <span v-if="scope.row.state === 10">换货失败</span>
                </span> -->
                <!-- <span style="float:right; margin-right:50px"><el-tag v-if="scope.row.state === 5 || scope.row.state === 6 || scope.row.state === 7">已售后</el-tag></span> -->
                <!-- <span v-if="props.row.returnType !== 1">
                  <el-button v-if="props.row.returnStatus === 5 || props.row.returnStatus === 7" type="primary" style="float: right" size="mini" @click="queryLogistics(scope.row.deliveryNo)">物流</el-button>
                  <el-button type="warning" style="float: right; margin-right: 20px" size="mini" @click="updateLogistics(scope.row.id, scope.row.deliveryNo)">修改物流</el-button>
                </span> -->
              <!-- </template>
            </el-table-column>
          </el-table>
        </el-form>
      </template>
      </el-table-column> -->
      <!-- <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column> -->
      <el-table-column
        prop="returnId"
        header-align="center"
        align="center"
        label="ID">
      </el-table-column>
      <el-table-column
        prop="orderNo"
        header-align="center"
        align="center"
        label="订单号">
      </el-table-column>
      <el-table-column
        prop="payUserName"
        header-align="center"
        align="center"
        label="姓名">
      </el-table-column>
      <el-table-column
        prop="iphone"
        header-align="center"
        align="center"
        label="电话">
      </el-table-column>
      <el-table-column
        prop="returnType"
        header-align="center"
        align="center"
        label="退货类型">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.returnType === 1">仅退款</el-tag>
          <el-tag type="success" v-if="scope.row.returnType === 2">退货并退款</el-tag>
          <el-tag type="info" v-if="scope.row.returnType === 3">换货</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="status"
        header-align="center"
        align="center"
        label="退货状态">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === 1">已申请</el-tag>
          <el-tag type="success" v-if="scope.row.status === 2">审核通过</el-tag>
          <el-tag type="warning" v-if="scope.row.status === 3 && scope.row.returnType === 1">退款中</el-tag>
          <el-tag type="warning" v-if="scope.row.status === 3 && scope.row.returnType === 2">退货中</el-tag>
          <el-tag type="warning" v-if="scope.row.status === 3 && scope.row.returnType === 3">换货中</el-tag>
          <el-tag type="warning" v-if="scope.row.status === 4 && scope.row.returnType === 1">退款成功</el-tag>
          <el-tag type="warning" v-if="scope.row.status === 4 && scope.row.returnType === 2">退货成功</el-tag>
          <el-tag type="warning" v-if="scope.row.status === 4 && scope.row.returnType === 3">换货成功</el-tag>
          <el-tag type="danger" v-if="scope.row.status === 5">审核未通过</el-tag>
          <el-tag type="success" v-if="scope.row.status === 6">失败</el-tag>
          <el-tag type="info" v-if="scope.row.status === 7">已撤销</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="applyReturnTime"
        header-align="center"
        align="center"
        label="申请时间">
      </el-table-column>
      <el-table-column
        prop="returnGoodsCount"
        header-align="center"
        align="center"
        label="商品总数量">
      </el-table-column>
      <el-table-column
        prop="goodsAmount"
        header-align="center"
        align="center"
        label="订单金额">
        <template slot-scope="scope">
          <span v-if="scope.row.goodsAmount != null">￥ {{scope.row.goodsAmount}}</span>
          <span v-if="scope.row.goodsAmount == null">￥ 0</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="applyReturnMoney"
        header-align="center"
        align="center"
        label="退款金额">
        <template slot-scope="scope">
          <span v-if="scope.row.applyReturnMoney != null">￥ {{scope.row.applyReturnMoney}}</span>
          <span v-if="scope.row.applyReturnMoney == null">￥ 0</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="applyReturnIntegral"
        header-align="center"
        align="center"
        label="退积分">
      </el-table-column>
      <el-table-column
        prop="applyReturnFreight"
        header-align="center"
        align="center"
        label="退款运费">
      </el-table-column>
      <el-table-column
        prop="applyReturnRemark"
        header-align="center"
        align="center"
        label="退货备注">
      </el-table-column>
      <el-table-column
        prop="userShipCode"
        header-align="center"
        align="center"
        label="物流信息">
        <template slot-scope="scope">
          <!-- 用户在进行申请后，并进行审核的操作，根据供应商未收到货的状态来显示用户的寄件物流信息 -->
          <span v-if="scope.row.returnStatus === 2 && scope.row.supplierGetGoods === 0 && scope.row.returnType !== 1">
            <!-- 查看用户发货的物流信息 -->
            <el-button type="primary" size="mini" @click="queryLogistics(scope.row.userShipCode)">物流信息</el-button><br/><br/>
            <el-button type="warning" size="mini" @click="updateLogistics(scope.row.returnId, 1, scope.row.userShipCode, scope.row.userShipId)">修改物流</el-button>
          </span>
          <!-- 如果用户是仅退款 -->
          <!-- <p v-if="scope.row.returnType === 1">
            <span v-if="scope.row.returnStatus === 5 || scope.row.returnStatus === 7">
              <el-button type="primary" size="mini" @click="queryLogistics(scope.row.userShipCode)">物流信息</el-button><br/><br/>
              <el-button type="warning" size="mini" @click="updateLogistics(scope.row.returnId, 1, scope.row.userShipCode, scope.row.userShipId)">修改物流</el-button>
            </span>
          </p> -->
          <!-- 如果用户是换货，并且供应商已经再次发过货 -->
          <span v-if="scope.row.supplierGetGoods === 1 && scope.row.returnType === 3 && scope.row.returnStatus === 3 && scope.row.exchangeGetGoods === 0 && scope.row.supplierShipCode !== null">
            <el-button type="primary" size="mini" @click="queryLogistics(scope.row.supplierShipCode)">物流信息</el-button><br/><br/>
            <el-button type="warning" size="mini" @click="updateLogistics(scope.row.returnId, 2, scope.row.supplierShipCode, scope.row.supplierShipId)">修改物流</el-button>
          </span>
        </template>
      </el-table-column>
      <!-- <el-table-column
        header-align="center"
        align="center"
        label="核销"
        width="160px">
        <template slot-scope="scope">
          <el-switch
            v-if="scope.row.status === 4"
            v-model="scope.row.returnStatus"
            active-color="#13ce66"
            inactive-color="#ff4949"
            active-text="核销"
            inactive-text="不核销"
            @change="writeOffChange(scope.row.status, scope.row.returnId)">
          </el-switch>
        </template>
      </el-table-column> -->
      <el-table-column
        prop="supplierReceivable"
        header-align="center"
        align="center"
        label="供应商是否打款给公司">
        <template slot-scope="scope">
          <span v-if="scope.row.status === 2 && scope.row.supplierReceivable === null">
            <el-button type="danger" size="mini" v-if="scope.row.returnType === 1 || scope.row.returnType === 2" @click="makeMoney(scope.row.returnId, 1)">是</el-button>
            <el-button type="danger" size="mini" v-if="scope.row.returnType === 1 || scope.row.returnType === 2" @click="makeMoney(scope.row.returnId, 0)">否</el-button>
          </span>
          <el-tag v-if="scope.row.supplierReceivable === 0">未打款</el-tag>
          <el-tag v-if="scope.row.supplierReceivable === 1">已打款</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.returnId)">查看详情</el-button>
          <el-button type="text" size="success" v-if="scope.row.returnStatus === 1" @click="toExamine(scope.row.returnId, 1, scope.row.goodsCartId, scope.row.returnType)">审核通过</el-button>
          <el-button type="text" size="warning" v-if="scope.row.returnStatus === 1" @click="toExamine(scope.row.returnId, 2, scope.row.goodsCartId, scope.row.returnType)">审核不通过</el-button>
          <!-- 用户在进行申请后，并进行审核的操作，根据供应商未收到货的状态来显示用户的寄件物流信息,只有在换货的时候才进行确认收货，别的类型都进行核销 -->
          <span v-if="scope.row.returnStatus === 3 && scope.row.supplierGetGoods === 0 && scope.row.returnType === 3">
            <el-button type="info" size="mini" @click="vendorConfirmation(scope.row.returnId, scope.row.returnType)">供应商确认收货</el-button>
          </span>
          <!-- 退货-》如果用户没有点击寄件操作，可以给用户进行寄件操作 -->
          <span v-if="scope.row.returnStatus === 2 && scope.row.supplierGetGoods === 0 && scope.row.returnType === 2">
            <el-button type="warning" size="mini" @click="userMail(scope.row.returnId)">用户寄件</el-button>
          </span>
          <!-- 退货-》供应商确认收货 -->
          <span v-if="scope.row.returnStatus === 3 && scope.row.supplierGetGoods === 0 && scope.row.returnType === 2">
            <el-button type="info" size="mini" @click="vendorConfirmation2(scope.row.returnId)">供应商确认收货</el-button>
          </span>
          <!-- 换货-》如果用户没有点击寄件操作，可以给用户进行寄件操作 -->
          <span v-if="scope.row.returnStatus === 2 && scope.row.supplierGetGoods === 0 && scope.row.returnType === 3">
            <el-button type="warning" size="mini" @click="userMail(scope.row.returnId)">用户寄件</el-button>
          </span>
          <!-- 如果用户是换货，则要进行再次发货的操作 -->
          <span v-if="scope.row.supplierGetGoods === 1 && scope.row.returnType === 3 && scope.row.returnStatus === 3 && scope.row.exchangeGetGoods === 0 && scope.row.supplierShipCode === null">
            <el-button type="danger" size="mini" @click="supplierDelivery(scope.row.returnId)">发货</el-button>
          </span>
          <el-button type="danger" v-if="scope.row.returnType === 1 && scope.row.returnStatus === 2 && scope.row.supplierReceivable === 0" size="mini" @click="writeOff(scope.row.returnId)">核销</el-button>
          <!-- 如果是仅退款，并且审核已经通过了和供应商已经打款给公司了，则可进行退款操作 -->
          <el-button type="danger" v-if="scope.row.returnType === 1 && scope.row.returnStatus === 3 && scope.row.supplierReceivable === 1" size="mini" @click="executionPayment(scope.row.returnId, scope.row.orderNo)">执行退款</el-button>
          <!-- 如果是退货，供应商已经收到货，并且打款给了公司，先进行核销 -->
          <el-button type="danger" v-if="scope.row.returnType === 2 && scope.row.returnStatus === 3 && scope.row.supplierReceivable === 0 && scope.row.supplierGetGoods === 1" size="mini" @click="writeOff(scope.row.returnId)">核销</el-button>
          <!-- 如果是退货，供应商已经收到货，并且打款给公司了 -->
          <el-button type="danger" v-if="scope.row.returnType === 2 && scope.row.returnStatus === 3 && scope.row.supplierReceivable === 1" size="mini" @click="executionPayment(scope.row.returnId, scope.row.orderNo)">执行退款</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <to-examine v-if="addOrUpdateVisible" ref="toExamine" @refreshDataList="getDataList"></to-examine>
    <deliver-goods v-if="addOrUpdateVisible" ref="deliverGoods" @refreshDataList="getDataList"></deliver-goods>
    <execution-payment v-if="addOrUpdateVisible" ref="executionPayment" @refreshDataList="getDataList"></execution-payment>
    <query-logistics v-if="addOrUpdateVisible" ref="queryLogistics" @refreshDataList="getDataList"></query-logistics>
    <update-logistics v-if="addOrUpdateVisible" ref="updateLogistics" @refreshDataList="getDataList"></update-logistics>
    <supplier-delivery v-if="addOrUpdateVisible" ref="supplierDelivery" @refreshDataList="getDataList"></supplier-delivery>
    <vendor-confirmation v-if="addOrUpdateVisible" ref="vendorConfirmation" @refreshDataList="getDataList"></vendor-confirmation>
    <user-mail v-if="addOrUpdateVisible" ref="userMail" @refreshDataList="getDataList"></user-mail>
  </div>
</template>

<script>
  import AddOrUpdate from './shoppingorderreturn-add-or-update'
  import toExamine from './to-examine'
  import deliverGoods from './deliver-goods'
  import executionPayment from './execution-payment'
  import queryLogistics from '../goodsorder/logisticsinformation'
  import updateLogistics from './return-logisticsinformation'
  import supplierDelivery from './supplier-delivery'
  import vendorConfirmation from './vendor-confirmation'
  import userMail from './user-mail'
  export default {
    data () {
      return {
        dataForm: {
          keywords: '',
          startTime: '',
          endTime: '',
          returnType: '',
          returnStatus: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false,
        examine: {
          supplierDeliveryName: '',
          upplierDeliveryIphone: '',
          supplierDeliveryAddress: '',
          supplierDeliveryRemark: ''
        }
      }
    },
    components: {
      AddOrUpdate,
      toExamine,
      deliverGoods,
      executionPayment,
      queryLogistics,
      updateLogistics,
      supplierDelivery,
      vendorConfirmation,
      userMail
    },
    activated () {
      this.getDataList()
    },
    created () {
      this.getParams()
    },
    methods: {
      getParams () {
        const routerParams = this.$route.query.orderId
        console.log(routerParams)
      },
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/returnGoods/queryShoppingMallOrderReturnList'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'keywords': this.dataForm.keywords,
            'startTime': this.dataForm.startTime,
            'endTime': this.dataForm.endTime,
            'returnType': this.dataForm.returnType,
            'returnStatus': this.dataForm.returnStatus
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.data.list
            this.totalPage = data.data.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      // 新增 / 修改
      addOrUpdateHandle (id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      // 查看物流
      queryLogistics (shipCode) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.queryLogistics.init(1, shipCode)
        })
      },
      // 修改物流
      updateLogistics (returnId, type, shipcode, shipId) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.updateLogistics.init(returnId, type, shipcode, shipId)
        })
      },
      // 换货-》供应商发货
      supplierDelivery (returnId) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.supplierDelivery.init(returnId)
        })
      },
      // 替用户寄件
      userMail (returnId) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.userMail.init(returnId)
        })
      },
      // 删除
      deleteHandle (id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.returnId
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/generator/shoppingorderreturn/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },
      executionPayment (returnId, orderNo) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.executionPayment.init(returnId, orderNo)
        })
      },
      // 供应商确认发货
      vendorConfirmation2 (returnId) {
        this.$http({
          url: this.$http.adornUrl(`/returnGoods/modifyVendorConfirmation/${returnId}`),
          method: 'post',
          data: this.$http.adornData()
        }).then(({data}) => {
          let s = JSON.parse(data.data)
          if (data && s.code === 200) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.getDataList()
              }
            })
          } else {
            this.$message.error(s.msg)
          }
        })
      },
      vendorConfirmation (returnId, returnType) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.vendorConfirmation.init(returnId, returnType)
        })
      },
      // 是否打款给公司
      makeMoney (returnId, type) {
        this.$http({
          url: this.$http.adornUrl(`/returnGoods/modifyMakeMoneyType/${returnId}/${type}`),
          method: 'post',
          data: this.$http.adornData()
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.getDataList()
              }
            })
          } else {
            this.$message.error(data.msg)
          }
        })
      },
      // 核销操作
      writeOff (returnId) {
        this.$http({
          url: this.$http.adornUrl(`/returnGoods/writeOffByReturnId/${returnId}`),
          method: 'post',
          data: this.$http.adornData()
        }).then(({data}) => {
          let s = JSON.parse(data.data)
          if (data && s.code === 200) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.getDataList()
              }
            })
          } else {
            this.$message.error(s.message)
          }
        })
      },
      // 在退换货审核通过后对该笔订单进行发货操作
      deliverGoods (returnId, goodsCartId, returnStatus) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.deliverGoods.init(returnId, goodsCartId, returnStatus)
        })
      },
      // 审核
      toExamine (returnId, type, goodsCartId, returnType) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.toExamine.init(returnId, type, goodsCartId, returnType)
        })
        // let supplierDeliveryName = ''
        // let supplierDeliveryIphone = ''
        // let supplierDeliveryAddress = ''
        // let supplierDeliveryRemark = ''
        // 退货并退款和退货
        // alert(returnType)
        // debugger
        // if (returnType === 2 || returnType === 3) {
        //   this.$prompt('供应商收货联系人', '提示', {
        //     confirmButtonText: '确定',
        //     cancelButtonText: '取消',
        //     inputType: 'input'
        //   // inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
        //   // inputErrorMessage: '邮箱格式不正确'
        //   }).then(({ value }) => {
        //     if (value === null || value === '') {
        //       this.$message.error('供应商收货联系人')
        //       return false
        //     }
        //     this.supplierDeliveryName = value
        //   }).catch(() => {
        //     this.$message({
        //       type: 'info',
        //       message: '取消输入'
        //     })
        //   })
        // }
        // this.$prompt('请输入审核备注', '提示', {
        //   confirmButtonText: '确定',
        //   cancelButtonText: '取消',
        //   inputType: 'textarea'
        //   // inputPattern: !/^[\u4E00-\u9FA5\uF900-\uFA2D\w]+$/,
        //   // inputErrorMessage: '审核备注不能为空'
        // }).then(({ value }) => {
        //   if (value === null || value === '') {
        //     this.$message.error('审核内容不能为空！')
        //     return false
        //   }
        // }).catch(() => {
        //   this.$message({
        //     type: 'info',
        //     message: '取消输入'
        //   })
        // })
        // this.$http({
        //   url: this.$http.adornUrl(`/returnGoods/modifyReturnStatusById/${returnId}/${type}/${goodsCartId}`),
        //   method: 'post',
        //   data: this.$http.adornData()
        // }).then(({data}) => {
        //   if (data && data.code === 0) {
        //     this.$message({
        //       message: '操作成功',
        //       type: 'success',
        //       duration: 1500,
        //       onClose: () => {
        //         this.getDataList()
        //       }
        //     })
        //   } else {
        //     this.$message.error(data.msg)
        //   }
        // })
      }
    }
  }
</script>
